package com.gaohe.web.controller.hotal;

import com.gaohe.common.annotation.Log;
import com.gaohe.common.core.controller.BaseController;
import com.gaohe.common.core.domain.AjaxResult;
import com.gaohe.common.core.page.TableDataInfo;
import com.gaohe.common.enums.BusinessType;
import com.gaohe.common.utils.poi.ExcelUtil;
import com.gaohe.hotal.domain.HotGuestReservation;
import com.gaohe.hotal.service.IHotGuestReservationService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户预订Controller
 *
 * @author ruoyi
 * @date 2025-07-02
 */
@RestController
@RequestMapping("/hotal/reservation")
public class HotGuestReservationController extends BaseController
{
    @Autowired
    private IHotGuestReservationService hotGuestReservationService;

    /**
     * 查询客户预订列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:reservation:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotGuestReservation hotGuestReservation)
    {
        startPage();
        List<HotGuestReservation> list = hotGuestReservationService.selectHotGuestReservationList(hotGuestReservation);
        return getDataTable(list);
    }

    /**
     * 导出客户预订列表
     */
    @PreAuthorize("@ss.hasPermi('hotal:reservation:export')")
    @Log(title = "客户预订", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotGuestReservation hotGuestReservation)
    {
        List<HotGuestReservation> list = hotGuestReservationService.selectHotGuestReservationList(hotGuestReservation);
        ExcelUtil<HotGuestReservation> util = new ExcelUtil<HotGuestReservation>(HotGuestReservation.class);
        util.exportExcel(response, list, "客户预订数据");
    }

    /**
     * 获取客户预订详细信息
     */
    @PreAuthorize("@ss.hasPermi('hotal:reservation:query')")
    @GetMapping(value = "/{reservationId}")
    public AjaxResult getInfo(@PathVariable("reservationId") Long reservationId)
    {
        return success(hotGuestReservationService.selectHotGuestReservationByReservationId(reservationId));
    }

    /**
     * 新增客户预订
     */
    @PreAuthorize("@ss.hasPermi('hotal:reservation:add')")
    @Log(title = "客户预订", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotGuestReservation hotGuestReservation)
    {
        return toAjax(hotGuestReservationService.insertHotGuestReservation(hotGuestReservation));
    }

    /**
     * 修改客户预订
     */
    @PreAuthorize("@ss.hasPermi('hotal:reservation:edit')")
    @Log(title = "客户预订", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotGuestReservation hotGuestReservation)
    {
        return toAjax(hotGuestReservationService.updateHotGuestReservation(hotGuestReservation));
    }

    /**
     * 删除客户预订
     */
    @PreAuthorize("@ss.hasPermi('hotal:reservation:remove')")
    @Log(title = "客户预订", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reservationIds}")
    public AjaxResult remove(@PathVariable Long[] reservationIds)
    {
        return toAjax(hotGuestReservationService.deleteHotGuestReservationByReservationIds(reservationIds));
    }
}
